package formal.linkedList;

/**
 * @author DengYuan2
 * @create 2021-01-05 20:54
 */
public class E_160 {

    public static void main(String[] args) {

    }


    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode tmp1 = headA;
        ListNode tmp2 = headB;
        while (tmp1 != tmp2) {
            tmp1 = (tmp1 == null) ? headB : tmp1.next;
            tmp2 = (tmp2 == null) ? headA : tmp2.next;
        }
        return tmp1;
    }
}